﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Linq;
using QuanLyKhachSan.report;
namespace QuanLyKhachSan
{
    public partial class frmBaoCaoDoanhThu : DevExpress.XtraEditors.XtraForm
    {
        DataClassesKhachSanDataContext db = new DataClassesKhachSanDataContext(SystemInfo.pub_ConnString);
        DataTable dt = new DataTable();
        public frmBaoCaoDoanhThu()
        {
            InitializeComponent();
        }

        private void btBaoCao_Click(object sender, EventArgs e)
        {
            if (dTuNgay .EditValue != null && dDenNgay.EditValue != null )
            {
                this.fillReport();
            }
        }

        void fillReport()
        {
            var doanhthu = (db.doanhthu(DateTime.Parse(dTuNgay.EditValue.ToString()), DateTime.Parse(dDenNgay.EditValue.ToString()))).ToList();
            for (int i = 0; i < doanhthu.Count; i++)
            {
                dt.Rows.Add(new object[]
                 {
                      
                      doanhthu [i].p_id,
                       doanhthu [i].p_ma,
                        doanhthu [i].TP_LOAI_GIA,
                        doanhthu [i].sl,
                        doanhthu [i].CTTP_DONGIA ,
                        doanhthu [i].thanhtienphong,
                         doanhthu [i].Bar ,
                        doanhthu [i].dichvu
       
                 });

                rptBaoCaoDoanhThu reportbaocao = new rptBaoCaoDoanhThu();
                reportbaocao.SetDataSource(dt);
                crystalReportViewer1.ReportSource = reportbaocao;

            }
        }

        private void frmBaoCaoDoanhThu_Load(object sender, EventArgs e)
        {
            
            dt.Columns.Add("p_id");
            dt.Columns.Add("p_ma");
            dt.Columns.Add("TP_LOAI_GIA", System.Type.GetType("System.Boolean"));
            dt.Columns.Add("sl");
            dt.Columns.Add("CTTP_DONGIA", System.Type.GetType("System.Decimal"));
            dt.Columns.Add("thanhtienphong", System.Type.GetType("System.Decimal"));
            dt.Columns.Add("Bar", System.Type.GetType("System.Decimal"));
            dt.Columns.Add("dichvu", System.Type.GetType("System.Decimal"));
            
            

        }
    }
}